var winston = require('winston');
var QRCode = require('../lib/qrcode');
var defaultDarkColor = '#000000';
var defaultLightColor = '#ffffff';
var defaultWidth = 280;

module.exports = function(req, res, next){
	var content = req.params.content;
	var lightColor = req.query.lightColor || defaultLightColor;
	var darkColor = req.query.darkColor || defaultDarkColor;
	var width = Number.from(req.query.width) || defaultWidth;

	var qrcode = new QRCode('qrcode', {
				width : width, 
				height : width,
				typeNumber : 4,
				colorDark : darkColor,
				colorLight : lightColor
		});
	qrcode.makeCode(content);
	res.set('Content-Type', 'image/png');
	res.send(qrcode.toBuffer());

}